package homework.qingming.calc.operations;

import homework.util.BigDecimalMath;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class DivOperation extends BaseOperation {

    public DivOperation() {
        super('/', 2);
    }

    @Override
    public BigDecimal operation(BigDecimal a, BigDecimal b) {
        if(b.compareTo(BigDecimal.ZERO) == 0)
            throw new ArithmeticException("除0错误");
        return a.divide(b, 100, RoundingMode.HALF_UP);
    }
}
